import {themes as prismThemes} from 'prism-react-renderer';
import type {Config} from '@docusaurus/types';
import type * as Preset from '@docusaurus/preset-classic';
const simplePlantUML = require("@akebifiky/remark-simple-plantuml");
import remarkMath from 'remark-math';
import rehypeKatex from 'rehype-katex';

const config: Config = {
  title: '码经心旅',
  tagline: '腹有诗书气自华',
  favicon: 'img/logo.png',

  // Set the production url of your site here
  url: 'https://site.wwkq.top',
  // Set the /<baseUrl>/ pathname under which your site is served
  // For GitHub pages deployment, it is often '/<projectName>/'
  baseUrl: '/',

  // GitHub pages deployment config.
  // If you aren't using GitHub pages, you don't need these.
  organizationName: '王开琦', // Usually your GitHub org/user name.
  projectName: 'blog', // Usually your repo name.

  onBrokenLinks: 'throw',
  onBrokenMarkdownLinks: 'warn',

  // Even if you don't use internationalization, you can use this field to set
  // useful metadata like html lang. For example, if your site is Chinese, you
  // may want to replace "en" with "zh-Hans".
  i18n: {
    defaultLocale: 'zh-CN',
    locales: ['zh-CN'],
    localeConfigs: {
      en: {
        htmlLang: 'zh-CN',
      },
    },
  },
  markdown: {
    mermaid: true
  },
  themes: ['@docusaurus/theme-mermaid','@docusaurus/theme-live-codeblock'],
  presets: [
    [
      'classic',
      {
        docs: {
          breadcrumbs: true, // 侧边栏面包屑
          sidebarPath: './sidebars.ts',
          remarkPlugins: [remarkMath,simplePlantUML],
          rehypePlugins: [rehypeKatex],
          // Please change this to your repo.
          // Remove this to remove the "edit this page" links.
          // editUrl:
          //   'https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/',
        },
        // blog: {
        //   showReadingTime: true,
        //   feedOptions: {
        //     type: ['rss', 'atom'],
        //     xslt: true,
        //   },
        //   // Please change this to your repo.
        //   // Remove this to remove the "edit this page" links.
        //   editUrl:
        //     'https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/',
        //   // Useful options to enforce blogging best practices
        //   onInlineTags: 'warn',
        //   onInlineAuthors: 'warn',
        //   onUntruncatedBlogPosts: 'warn',
        // },
        theme: {
          customCss: './src/css/custom.css',
        },
      } satisfies Preset.Options,
    ],
  ],

  themeConfig: {
    // Replace with your project's social card
    image: 'img/logo.png',
    metadata: [
      {
        name: 'keywords',
        content: 'Java开发, Spring, 架构设计, 后端开发, 软件设计师, 系统架构师, 技术博客, 编程学习, DDD, 微服务, 数据库, 算法, 设计模式',
      },
      {
        name: 'description',
        content: '一个专注于Java开发、架构设计、软考备考的技术知识库，包含了完整的学习路线、实战项目和面试攻略。',
      },
      {
        name: 'author',
        content: '王开琦',
      },
      {name: 'og:type', content: 'website'},
      {name: 'og:title', content: '码经心旅 - 技术知识库'},
      {name: 'og:description', content: '专注于Java开发与架构设计的技术知识分享平台'},
      {name: 'og:image', content: 'img/logo.png'},
      {name: 'og:url', content: 'https://site.wwkq.top'},
      {name: 'og:site_name', content: '码经心旅'},
      {name: 'twitter:card', content: 'summary_large_image'},
      {name: 'twitter:title', content: '码经心旅 - 技术知识库'},
      {name: 'twitter:description', content: '专注于Java开发与架构设计的技术知识分享平台'},
      {name: 'twitter:image', content: 'img/logo.png'},
      {name: 'theme-color', content: '#2e8555'},
      {name: 'viewport', content: 'width=device-width, initial-scale=1.0'},
      {name: 'format-detection', content: 'telephone=no'},
      {name: 'apple-mobile-web-app-capable', content: 'yes'},
      {name: 'apple-mobile-web-app-status-bar-style', content: 'black'},
    ],
    algolia: {
      // Algolia 提供的应用 ID
      appId: 'AQHAXJDYT9',
      
      // 公开的 API 密钥：可以安全提交
      apiKey: '1701df234a9fc9ce786e5de129c6216d',
      
      // 索引名称
      indexName: 'wwkq',
      
      // 可选：启用上下文搜索 (默认值)
      contextualSearch: true,
      
      // 可选：搜索页面路径 (默认值)
      searchPagePath: 'search',
    },
    docs: {
      sidebar: {
        hideable: true, // 侧边栏可隐藏
        autoCollapseCategories: true, // 自动折叠侧边栏
      }
    },
    navbar: {
      title: '码经心旅',
      logo: {
        alt: '码经心旅',
        src: 'img/logo.png',
      },
      items: [
        {
          label: '📚 自我提升',
          items: [
            {
              label: '📊 软件设计师（中级）',
              to: '/docs/roadmap/software-designer'
            },
            {
              label: '👑 系统架构师（高级）',
              to: '/docs/roadmap/system-architect'
            },
            {
              label: '🎓 计算机考研 408',
              to: '/docs/roadmap/cs408',
            },
          ],
        },
        {
          label: '💻 编程基础',
          items: [
            { label: '🏗️ 数据结构与算法', to: '/docs/programming/algorithms' },
            { label: '📐 设计模式', to: '/docs/programming/design-patterns' },
            { label: '🔧 计算机基础', to: '/docs/programming/computer-basics' },
            { label: '🌐 计算机网络', to: '/docs/programming/network' },
            { label: '🎯 Java开发', to: '/docs/programming/java-developer' },
            { label: '🔤 英语学习', to: '/docs/programming/english' },
            { label: '⚙️ C语言', to: '/docs/programming/c' },
            {
              label: '⚡ 前端开发',
              to: '/docs/programming/front',
            },
            {
              label: '🗃️ SQL',
              to: '/docs/programming/sql',
            }
          ],
        },
        {
          label: '🚀 核心技术',
          items: [
            { label: '☕ Java核心', to: '/docs/core/java' },
            { label: '🍃 Spring生态', to: '/docs/core/spring' },
            { label: '🗄️ 数据库', to: '/docs/core/database' },
            { label: '🔄 中间件', to: '/docs/core/middleware' },
          ],
        },
        {
          label: '🏛️ 架构设计',
          items: [
            { label: '🎨 DDD领域驱动', to: '/docs/architecture/ddd' },
            { label: '🔄 微服务架构', to: '/docs/architecture/microservices' },
            { label: '🏢 分布式系统', to: '/docs/architecture/distributed-systems' },
            { label: '🛡️ 系统安全', to: '/docs/architecture/security' },
          ],
        },
        {
          label: '🛠️ 开发工具',
          items: [
            { label: '🐧 Linux基础', to: '/docs/tools/linux' },
            { label: '🐳 Docker容器', to: '/docs/tools/docker' },
            { label: '🔄 Git版本控制', to: '/docs/tools/git' },
            { label: '🤖 Cursor IDE', to: '/docs/tools/cursor/context' },
            { label: '⚡ 效率工具', to: '/docs/tools/efficiency' },
          ],
        },
        // {
        //   label: '📈 项目实战',
        //   items: [
        //     { label: '🎲 抽奖系统', to: '/docs/projects/lottery' },
        //     { label: '🛍️ 电商系统', to: '/docs/projects/mall' },
        //     { label: '🤖 Spring框架', to: '/docs/projects/spring-framework' },
        //
        //   ],
        // },
        {
          label: '📝 面试专题',
          items: [
            { label: '📋 面试题集', to: '/docs/interview/questions' },
            { label: '🎯 算法题解', to: '/docs/interview/algorithms' },
            { label: '💡 系统设计', to: '/docs/interview/system-design' },
          ],
        },
        {
          href: 'https://gitee.com/wkqgitee',
          position: 'right',
          className: 'header-gitee-link',
          'aria-label': 'Gitee repository',
        },
      ],
    },
    footer: {
      copyright: `Copyright © ${new Date().getFullYear()} site.wwkq.top`,
    },
    prism: {
      theme: prismThemes.github,
      darkTheme: prismThemes.dracula,
    },
    mermaid: {
      theme: {light: 'forest', dark: 'dark'},
    },
    sitemap: {
      changefreq: 'weekly',
      priority: 0.5,
    },
  } satisfies Preset.ThemeConfig,
  customFields: {
    description: '专注于Java开发与架构设计的技术知识分享平台',
    keywords: [
      'Java',
      '架构设计',
      '软件开发',
      '技术博客',
      '学习路线',
      '实战项目',
      '面试题',
      '软考',
      'Spring',
      '微服务',
    ],
  },
  stylesheets: [
    {
      href: 'https://cdn.jsdelivr.net/npm/katex@0.13.24/dist/katex.min.css',
      type: 'text/css',
      integrity:
          'sha384-odtC+0UGzzFL/6PNoE8rX/SPcQDXBJ+uRepguP4QkPCm2LBxH3FA3y+fKSiJ+AmM',
      crossorigin: 'anonymous',
    },
  ],
  plugins: [
    [
      '@docusaurus/plugin-sitemap',
      {
        changefreq: 'weekly',
        priority: 0.5,
        ignorePatterns: ['/tags/**'],
        filename: 'sitemap.xml',
        id: 'plugins-sitemap'
      },
    ],
  ],
};

export default config;
